import util from '../../../utils/util'
import {
  GetMemberSjfk
} from '../../../config/api'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: 1,
    limit: 10,
    member_storage: '',
    isEmpty: false,
    feedbacks: [], //反馈列表数据
  },
  /**
   * 察看详情
   */
  CheckDetail: function (e) {
    // console.log('查看详情！',e.currentTarget.dataset.id);
    wx.navigateTo({
      url: '/pages/grid/feedback_detail/feedback_detail?id=' + e.currentTarget.dataset.id
    });
  },
  /**
   * 帮助解决
   */
  HelpSolve: function (e) {
    console.log('帮助解决！')
    wx.navigateTo({
      url: '/pages/grid/help_solve/help_solve?id=' + e.currentTarget.dataset.id
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    let member_storage = wx.getStorageSync("member")
    this.setData({
      member_storage
    })
    this.getList()
  },

  getList() {
    let that = this;
    let params = {
      page: that.data.page,
      limit: that.data.limit,
      member_id: that.data.member_storage.id
    };
    util.apiRequest(GetMemberSjfk, params, null).then(r => {
      console.log('上级反馈列表：', r.data.data.data);
      var newList = that.data.feedbacks.concat(r.data.data.data)

      if (r.data.data.data == '') {
        that.setData({
          feedbacks: newList
        })
        wx.showToast({
          title: '暂无更多',
          icon: 'none',
        })
      } else {
        that.setData({
          feedbacks: newList
        })
      }
      wx.hideLoading();

      if (newList.length == 0) {
        that.setData({
          isEmpty: true
        })
      } else {
        that.setData({
          isEmpty: false
        })
      }

    });
  },

  onReachBottom: function () {
    var that = this;
    var page = this.data.page;
    page++;
    that.setData({
      page: page
    })
    console.log('page++', page)
    this.getList();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})